#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>

using namespace std;

int main()
{
    int n, T1, T2, T3, T4;
    cin >> n >> T1 >> T2 >> T3 >> T4;
    int inf = 1e9;
    vector<vector<int>> dp(n + 1, vector<int>(2, inf));
    vector<vector<int>> h(n + 1, vector<int>(2));
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i][0];
        h[i][1] = 4 - h[i][0];
    }
    dp[1][0] = 0;
    dp[1][1] = T4;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (h[i][j] < h[i + 1][j] && h[i + 1][j] - h[i][j] <= 1)
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + T2);
                dp[i + 1][j ^ 1] = min(dp[i + 1][j ^ 1], dp[i][j] + T2 + T4);
            }
            if (h[i][j] > h[i + 1][j])
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + T3);
                dp[i + 1][j ^ 1] = min(dp[i + 1][j ^ 1], dp[i][j] + T3 + T4);
            }
            if (h[i][j] == h[i + 1][j])
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + T1);
                dp[i + 1][j ^ 1] = min(dp[i + 1][j ^ 1], dp[i][j] + T1 + T4);
            }
        }
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
}